<script  type="text/javascript" src="//dbmaintaince.investogain.com.au/js/jquery-1.6.2.min.js"></script>
<script type="text/javascript">
function make_uppercase(){
document.getElementById("CodetailComName").value=document.getElementById("CodetailComName").value.toUpperCase();
}
function calculateValue(fld){
if(fld!=0){
if(document.getElementById("CodtranNumber_"+fld).value!="" && document.getElementById("CodtranPrice_"+fld).value!="")
	document.getElementById("CodtranValue_"+fld).value=(document.getElementById("CodtranNumber_"+fld).value * document.getElementById("CodtranPrice_"+fld).value);
}else{
if(document.getElementById("CodtranNumber").value!="" && document.getElementById("CodtranPrice").value!="")
	document.getElementById("CodtranValue").value=(document.getElementById("CodtranNumber").value * document.getElementById("CodtranPrice").value);
}
}

function calculatePrice(fld){
if(fld!=0){
if(document.getElementById("CodtranNumber_"+fld).value!="" && document.getElementById("CodtranValue_"+fld).value!="")
	document.getElementById("CodtranPrice_"+fld).value=(document.getElementById("CodtranValue_"+fld).value / document.getElementById("CodtranNumber_"+fld).value);
}else{
if(document.getElementById("CodtranValue").value!="" && document.getElementById("CodtranNumber").value!="")
	document.getElementById("CodtranPrice").value=(document.getElementById("CodtranValue").value / document.getElementById("CodtranNumber").value);

}

}
jQuery(document).ready(function(){

var el=jQuery("#viewscreen"); 
height =window.screen.height-250;
el.height(height);

jQuery(".addtrans").click(function(){
	TranID=jQuery(this).attr("TranID");
	//jQuery("#addtransform").html()
	//alert(TranID);
	jQuery.get('<?php echo Configure::read('baseurl');?>admin/codtrans/add_trans/'+TranID, function(data) {
		jQuery('#addtransform').html(data);	  
		var target_offset = jQuery("#addtransform").offset();
		var target_top = target_offset.top;
		$('html, body').animate({scrollTop:target_top}, 500);
	});
}) 
});

function change_dir_name(selectedID,ID){
	jQuery.get('<?php echo Configure::read('baseurl');?>admin/codetails/change_dir_name/'+selectedID+"/"+ID, function(data) {
		jQuery("#dir_id_"+ID).html(data);
		jQuery("#change_dir_name_"+ID).hide();		
	});	
}
function change_dir_name_codtrans(selectedID,ID){
	jQuery.get('<?php echo Configure::read('baseurl');?>admin/codetails/change_dir_name_codtrans/'+selectedID+"/"+ID, function(data) {
		jQuery("#change_dir_name_codtrans_"+ID).html(data);		
	});	
}
</script>
<?php echo $this->element('menu'); ?>
<div id="viewscreen" style="width: 1600px;height:500px;overflow-y:scroll;overflow-x:none;">
<div class="codetails view" style="border-right:1px solid #666666">
	<!--Codetails Start-->
<h2><?php  __('Company ID:');?><?php echo $this->data['Codetail']['ComID']; ?></h2>
<?php echo $this->Html->link(__('Name Change', true), array('action' => 'name_change', $this->data['Codetail']['ComID'])); ?>
<?php echo $this->Form->create('Codetail',array('action'=>'edit'));?>
<?php echo $this->Form->input('ComID');?>
	<table border="0" style="width:775px" align="left"><?php $i = 0; $class = ' class="altrow"';?>
		<tr class="altrow">
			<td class="required"><label><?php __('ComName'); ?></label></td>
			<td colspan="3"><?php echo $this->Form->input('ComName',array("label"=>false,"div"=>false,'onkeyup'=>"make_uppercase();")); ?></td>
			<td class="required"><label><?php __('UrlTitle'); ?></label></td>
			<td colspan="3"><?php echo $this->Form->input('url_title',array("label"=>false,"div"=>false)); ?></td>
		</tr>
		<tr class="altrow">
			<td><label><?php __('StartDate'); ?></label></td>
			<td colspan="3"><?php echo $this->Form->input('StartDate',array("style"=>"width:30%","label"=>false,"div"=>false,'minYear' => '1950','maxYear' => date("Y"),'dateFormat' => 'DMY', 'empty' => '(choose one)'));?></td>
			<td><label><?php __('EndDate'); ?></label></td>
			<td colspan="3"><?php echo $this->Form->input('EndDate',array("style"=>"width:30%","label"=>false,"div"=>false,'minYear' => '1950','maxYear' => date("Y"),'dateFormat' => 'DMY', 'empty' => '(choose one)'));?></td>
		</tr>
		<tr class="altrow">
			<td><?php __('Code'); ?></td>
			<td><?php echo $this->Form->input('Code',array("label"=>false,"div"=>false)); ?></td>
			<td><?php __('CodeY'); ?></td>
			<td><?php echo $this->Form->input('CodeY',array("label"=>false,"div"=>false)); ?></td>
			<td><?php __('Exch'); ?></td>
			<td><?php echo $this->Form->input('Exch',array("label"=>false,"div"=>false)); ?></td>
			<td><?php __('Cat'); ?></td>
			<td><?php echo $this->Form->input('Cat',array("label"=>false,"div"=>false)); ?></td>
		</tr>		
		<tr class="altrow">
			<td><?php __('Listed'); ?></td>
			<td colspan="3"><?php echo $this->Form->input('Listed',array("style"=>"width:80px","label"=>false,"div"=>false,'minYear' => date("1950"),'maxYear' => date("Y"),'dateFormat' => 'DMY', 'empty' => '(choose one)')); ?></td>
			<td><?php __('delistDate'); ?></td>
			<td colspan="3"><?php echo $this->Form->input('delistDate',array("style"=>"width:80px","label"=>false,"div"=>false,'minYear' => date("1930"),'maxYear' => date("Y"),'dateFormat' => 'DMY', 'empty' => '(choose one)')); ?></td>
			
		</tr>
		<tr class="altrow">
			<td><?php __('GICS'); ?></td>
			<td><?php echo $this->Form->input('GICS',array("label"=>false,"div"=>false)); ?></td>
			<td><?php __('IndGrp'); ?></td>
			<td><?php echo $this->Form->input('IndustryGroup',array("label"=>false,"div"=>false)); ?></td>
			<td><?php __('ISIN'); ?></td>
			<td><?php echo $this->Form->input('ISIN',array("label"=>false,"div"=>false)); ?></td>	
			<td><?php __('Type'); ?></td>
			<td><?php echo $this->Form->input('Type',array("label"=>false,"div"=>false)); ?></td>			
		</tr>		
		<tr class="altrow">
			<td><?php __('Activit'); ?></td>
			<td colspan="7"><?php echo $this->Form->input('Activit',array("label"=>false,"div"=>false,"rows"=>3,"cols"=>45)); ?></td>			
		</tr>			
		<tr class="altrow">
			<td><?php __('CoAddr'); ?></td>
			<td colspan="3"><?php echo $this->Form->input('CoAddr',array("label"=>false,"div"=>false)); ?></td>
			<td><?php __('Website'); ?></td>
			<td colspan="3"><?php echo $this->Form->input('Website',array("label"=>false,"div"=>false)); ?></td>
		</tr>
		<tr class="altrow">		
			<td><?php __('Tel'); ?></td>
			<td colspan="3"><?php echo $this->Form->input('CoTel',array("label"=>false,"div"=>false)); ?></td>
			<td><?php __('InvCtr'); ?></td>
			<td colspan="3"><?php echo $this->Form->input('InvCtr',array("label"=>false,"div"=>false)); ?></td>
		</tr>
		<tr class="altrow">
			<td><?php __('Fax'); ?></td>
			<td colspan="3"><?php echo $this->Form->input('CoFax',array("label"=>false,"div"=>false)); ?></td>
			<td><?php __('Announce'); ?></td>
			<td colspan="3"><?php echo $this->Form->input('Announce',array("label"=>false,"div"=>false)); ?></td>					
		</tr>			
		<tr class="altrow">		
			<td><?php __('Regry'); ?></td>
			<td colspan="3"><?php echo $this->Form->input('Regry',array("label"=>false,"div"=>false)); ?></td>
			<td><?php __('AnnRep'); ?></td>
			<td colspan="3"><?php echo $this->Form->input('AnnRep',array("label"=>false,"div"=>false)); ?></td>
		</tr>
		<tr class="altrow">
			<td><?php __('CoSec'); ?></td>
			<td colspan="3"><?php echo $this->Form->input('CoSec',array("label"=>false,"div"=>false)); ?></td>
			<td><?php __('Email'); ?></td>
			<td colspan="3"><?php echo $this->Form->input('Email',array("label"=>false,"div"=>false)); ?></td>
		</tr>	
		<tr class="altrow">
			<td><?php __('Rating'); ?></td>
			<td colspan="3"><?php echo $this->Form->input('Rating',array("label"=>false,"div"=>false)); ?></td>
			<td><?php __('Directors'); ?></td>
			<td colspan="3"><?php echo $this->Form->input('director_url',array("label"=>false,"div"=>false)); ?></td>			
		</tr>
	</table>
	
	<p style="clear:both;">&nbsp;</p>
	<div class="deletebtn"><?php echo $this->Html->link(__('Delete', true), array('action' => 'delete', $this->data['Codetail']['ComID']), null, sprintf(__('Are you sure you want to delete # %s?', true), $this->data['Codetail']['ComID'])); ?></div>	
	<input type="submit" value="Update">
	<?php echo $this->Form->end();?>
	<!--Codetails End-->
	<!--Events start-->
<div class="related" style="clear:both;width:755px;">
<h2><?php __('Events');?></h2>
<?php echo $this->Form->create('Coevent',array('action'=>'add'));
	echo $this->Form->input('ComID',array("type"=>'hidden','value'=>$this->data['Codetail']['ComID']));
	echo $this->Form->input('return_page',array("type"=>'hidden','value'=>'view'));
	echo $this->Form->input('Position',array("type"=>'hidden'));
?>
<table cellpadding="0" cellspacing="0">
<tr class="altrow">
	<td width="150"><?php echo $this->Form->input('EventDate',array("label"=>false,"div"=>false,'minYear' => '1930','maxYear' => date("Y"),'dateFormat' => 'DMY','timeFormat'=>'24')); ?></td>
	<td width="450"><?php echo $this->Form->input('Event',array("rows"=>3,"label"=>false,"div"=>false)); ?></td>
	<td><?php echo $this->Form->input('Note',array("label"=>false,"div"=>false)); ?></td>
</tr>
</table>
<?php echo $this->Form->end(__('Add', true));?>	
<?php if (!empty($this->data['Coevent'])):?>	
	<?php if (count($this->data['Coevent'])>1):?>
	<table cellpadding = "0" cellspacing = "0">
	
	<?php
		$i = 0;
		foreach ($this->data['Coevent'] as $coevent):
			$class = null;
			if ($i++ % 2 == 0) {
				$class = ' class="altrow"';
			}
		?>
		<tr<?php echo $class;?>>
			<td>
				<?php echo $this->Form->create('Coevent',array('action'=>'edit/'.$coevent['EventID']));
				echo $this->Form->input('EventID',array("value"=>$coevent['EventID']));
				echo $this->Form->input('Position',array("value"=>$coevent['Position'],"type"=>"hidden"));
				echo $this->Form->input('return_page',array("type"=>'hidden','value'=>'view'));
				?>
				<table>
				<tr>
					<td width="150"><?php echo $this->Form->input('EventDate',array("value"=>$coevent['EventDate'],"label"=>false,"div"=>false,'minYear' => '1930','maxYear' => date("Y"),'dateFormat' => 'DMY','timeFormat'=>'24')); ?></td>
					<td width="450"><?php echo $this->Form->input('Event',array("rows"=>3,"value"=>$coevent['Event'],"label"=>false,"div"=>false)); ?></td>
					<td><?php echo $this->Form->input('Note',array("value"=>$coevent['Note'],"label"=>false,"div"=>false)); ?></td>
				</tr>
				</table>
				<div class="deletebtn"><?php echo $this->Html->link(__('Delete', true), array('controller' => 'coevents', 'action' => 'delete', $coevent['EventID']), null, sprintf(__('Are you sure you want to delete # %s?', true), $coevent['EventID'])); ?></div>
				<?php
				$options = array('label' => 'Update','name' => 'Update','div' => false);
				echo $this->Form->end($options);?>
			</td>
		</tr>
	<?php endforeach; ?>
	</table>	
	<?php else: ?>
<?php echo $this->Form->create('Coevent',array('action'=>'edit/'.$this->data['Coevent'][0]['EventID']));
echo $this->Form->input('EventID',array("value"=>$this->data['Coevent'][0]['EventID']));
echo $this->Form->input('Position',array("value"=>$this->data['Coevent'][0]['Position'],"type"=>"hidden"));
echo $this->Form->input('return_page',array("type"=>'hidden','value'=>'view'));
?>
<table cellpadding = "0" cellspacing = "0">
	<tr class="altrow">
		<td width="150"><?php echo $this->Form->input('EventDate',array("value"=>$this->data['Coevent'][0]['EventDate'],"label"=>false,"div"=>false,'minYear' => '1930','maxYear' => date("Y"),'dateFormat' => 'DMY','timeFormat'=>'24')); ?></td>
		<td width="450"><?php echo $this->Form->input('Event',array("value"=>$this->data['Coevent'][0]['Event'],"label"=>false,"div"=>false,"rows"=>3)); ?></td>
		<td><?php echo $this->Form->input('Note',array("value"=>$this->data['Coevent'][0]['Note'],"label"=>false,"div"=>false)); ?></td>
	</tr>	
</table>
<div class="deletebtn"><?php echo $this->Html->link(__('Delete', true), array('controller' => 'coevents', 'action' => 'delete', $this->data['Coevent'][0]['EventID']), null, sprintf(__('Are you sure you want to delete # %s?', true), $this->data['Coevent'][0]['EventID'])); ?></div>
<?php
$options = array('label' => 'Update','name' => 'Update','div' => false);
echo $this->Form->end($options);?>
<?php endif; ?>
<?php endif; ?>	
</div>
<!--Events End-->
</div>
<div class="related" style="width:800px;">
<h2><?php __('Directors');?></h2>
<?php 
//pr($this->data['Codexec']);
if (!empty($this->data['Codexec'])):
    if (count($this->data['Codexec'])>1){
	?>
	<table cellpadding="1">
	<tr>			
		<th style="width:115px;"><?php __('Name'); ?></th>		
		<th style="width:125px;"><?php __('Title1'); ?></th>
		<th style="width:125px;"><?php __('Title2'); ?></th>
		<th style="width:195px;"><?php __('App'); ?></th>
		<th><?php __('Resig'); ?></th>		
		<th></th>		
	</tr>
	<?php
		$i = 0;
		foreach ($this->data['Codexec'] as $codexec):
			$class = null;
            if($codexec['Resig']== "0000-00-00" OR $codexec['Resig']>date('Y-m-d H:i:s'))    {
			if ($i++ % 2 == 0) {
				$class = ' class="altrow"';
			}
                        
	?>
	<?php 
	echo $this->Form->create('Codexec',array('action'=>'edit/'.$codexec['id']));
	echo $this->Form->input('id',array("value"=>$codexec['id']));
	echo $this->Form->input('director_id',array("value"=>$codexec['director_id'],"type"=>"hidden"));
	echo $this->Form->input('return_page',array("type"=>'hidden','value'=>'view'));
	?>
	<tr<?php echo $class;?>><td colspan="6">
	<table cellpadding="0" cellspacing="1">
		<tr>			
			<td><?php echo $this->Form->input('Codexec.Name',array("style"=>"width:120px","value"=>$codexec['Director']['name'],"label"=>false,"div"=>false)); ?></td>			
			<td><?php echo $this->Form->input('Codexec.dir_title_id',array("style"=>"width:120px",'id'=>'CodexecTitle1_1','options'=>$titles,'empty'=>'ADD please',"selected"=>$codexec['dir_title_id'],"label"=>false,"div"=>false)); ?></td>
			<td><?php echo $this->Form->input('Codexec.dir_title_id2',array('id'=>'CodexecTitle2_2',"style"=>"width:120px",'options'=>$titles,'empty'=>'ADD please',"selected"=>$codexec['dir_title_id2'],"label"=>false,"div"=>false)); ?></td>
			<td width="200"><?php echo $this->Form->input('Codexec.App',array("value"=>$codexec['App'],"style"=>"width:60px","label"=>false,"div"=>false,'minYear' => '1950','maxYear' => date("Y"),'dateFormat' => 'DMY', 'empty' => '(choose one)')); ?></td>
			<td width="200"><?php echo $this->Form->input('Codexec.Resig',array("value"=>$codexec['Resig'],"style"=>"width:60px","label"=>false,"div"=>false,'minYear' => '1950','maxYear' => date("Y"),'dateFormat' => 'DMY', 'empty' => '(choose one)')); ?></td>
			<td width="10"><?php echo $this->Html->link(__('D', true), array('controller' => 'codexecs', 'action' => 'delete', $codexec['id']), array("style"=>"color:red"), sprintf(__('Are you sure you want to delete # %s?', true), $codexec['id'])); ?></td>
		</tr>
		</table>	
		<a href="javascript:void(0);" class="addtrans" TranID="<?php echo $codexec['id'];?>">TRANS</a><?php //echo $this->Html->link(__('Edit', true), array('controller' => 'codexecs', 'action' => 'edit', $codexec['id'])); ?>				
				<?php $options = array('label' => 'Update','name' => 'Update','div' => false);echo $this->Form->end($options);?>			
		</td>
		</tr>
	<?php } endforeach; ?>
	</table>	
<?php }else{ ?>
<?php echo $this->Form->create('Codexec',array('action'=>'edit/'.$this->data['Codexec'][0]['id']));
echo $this->Form->input('id',array("value"=>$this->data['Codexec'][0]['id']));
echo $this->Form->input('director_id',array("value"=>$this->data['Codexec'][0]['director_id'],"type"=>"hidden"));
echo $this->Form->input('return_page',array("type"=>'hidden','value'=>'view'));
echo $this->Form->input('DIRref',array("value"=>$this->data['Codexec'][0]['DIRref'],"type"=>"hidden","label"=>false,"div"=>false));
?>
<table cellpadding = "0" cellspacing = "0">
	<tr class="altrow">
		<td width="80"><?php __('Name'); ?></td>
		<td width="180"><?php echo $this->Form->input('Name',array("value"=>$this->data['Codexec'][0]['Director']['name'],"style"=>"width:200px","label"=>false,"div"=>false)); ?></td>
		<td></td>
		<td width="150"></td>
	</tr>
	<tr class="altrow">
		<td><?php __('title1'); ?></td>
		<td><?php echo $this->Form->input('dir_title_id',array('id'=>'CodexecTitle1_1','options'=>$titles,'empty'=>'ADD please',"selected"=>$this->data['Codexec'][0]['dir_title_id'],"label"=>false,"div"=>false)); ?></td>
		<td width="80"><?php __('title2'); ?></td>
		<td  width="150"><?php echo $this->Form->input('dir_title_id2',array('id'=>'CodexecTitle2_2','options'=>$titles,'empty'=>'ADD please',"selected"=>$this->data['Codexec'][0]['dir_title_id2'],"label"=>false,"div"=>false)); ?></td>
	</tr>
	<tr class="altrow">
		<td><?php __('App'); ?></td>
		<td><?php echo $this->Form->input('App',array("value"=>$this->data['Codexec'][0]['App'],"style"=>"width:70px","label"=>false,"div"=>false,'minYear' => '1950','maxYear' => date("Y"),'dateFormat' => 'DMY', 'empty' => '(choose one)')); ?></td>
		<td><?php __('Resig'); ?></td>
		<td><?php echo $this->Form->input('Resig',array("value"=>$this->data['Codexec'][0]['Resig'],"style"=>"width:70px","label"=>false,"div"=>false,'minYear' => '1950','maxYear' => date("Y"),'dateFormat' => 'DMY', 'empty' => '(choose one)')); ?></td>
	</tr>
</table>
<?php echo $this->Html->link(__('Delete', true), array('controller' => 'codexecs', 'action' => 'delete', $this->data['Codexec'][0]['id']), NULL, sprintf(__('Are you sure you want to delete # %s?', true), $this->data['Codexec'][0]['id'])); ?>
&nbsp;&nbsp;<?php $options = array('label' => 'Update','name' => 'Update','div' => false);echo $this->Form->end($options);?>	

<?php } ?>
<?php endif;?>

<?php 
echo $this->Form->create('Codexec',array('action'=>'add'));
echo $this->Form->input('ComID',array("type"=>'hidden','value'=>$this->data['Codetail']['ComID']));
echo $this->Form->input('return_page',array("type"=>'hidden','value'=>'view'));
?>
<p>&nbsp;</p>
<table cellpadding="0" cellspacing="0">
<tr><td width="250"><?php echo $this->Form->input('Name');?></td>
<td><?php echo $this->Form->input('dir_title_id',array('options'=>$titles,'empty'=>'ADD please'));?></td>
<td><?php echo $this->Form->input('dir_title_id2',array('options'=>$titles,'empty'=>'ADD please'));?></td>
<td>
<!--label for="CodexecApp">App</label>
<input type="text" id="CodexecApp" name="data[Codexec][App]" value="<?php echo date('d-m-Y');?>" maxlength="10" style="width:80px;" /-->
<?php echo $this->Form->input('App',array('style'=>"width:70px",'minYear' => '1950','maxYear' => date("Y"),'dateFormat' => 'DMY','empty'=>'choose one'));?>
</td>
<!--td><?php //echo $this->Form->input('Resig',array('minYear' => '1950','maxYear' => date("Y"),'dateFormat' => 'DMY', 'empty' => '(choose one)'));?></td-->
</tr>
</table>
<?php echo $this->Form->end(__('Add', true));?>
</div>

<div class="related" style="width:800px;float:right;">
	<h2><?php __('Transactions');?></h2>
<div id="addtransform">
<?php echo $this->Form->create('Codtran',array('action'=>'add'));
echo $this->Form->input('ComID',array("type"=>'hidden','value'=>$this->data['Codetail']['ComID']));
echo $this->Form->input('Company',array("type"=>'hidden','value'=>$this->data['Codetail']['ComName']));
echo $this->Form->input('Code',array("type"=>'hidden','value'=>$this->data['Codetail']['Code']));
echo $this->Form->input('return_page',array("type"=>'hidden','value'=>'view'));
echo $this->Form->input('Holding',array("type"=>"hidden"));

?>
<table cellpadding="0" cellspacing="0">
<tr>
<td width="210"><?php echo $this->Form->input('Date',array('minYear' => '1950','maxYear' => date("Y"),'dateFormat' => 'DMY')); ?></td>
<td width="160"><?php 
echo $this->Form->input('Name');
//echo $this->Form->input('director_id',array("empty"=>"Choose one","options"=>$directors));
?></td>
<td><?php echo $this->Form->input('Transaction');?></td>
<td><?php echo $this->Form->input('Number');?></td>
<td><?php echo $this->Form->input('Price',array('onfocus'=>"calculatePrice(0);"));?></td>
<td><?php echo $this->Form->input('Value',array('onfocus'=>"calculateValue(0);"));?></td>
</tr>
</table>
<?php echo $this->Form->end(__('Add', true));?>
</div>
<p>&nbsp;</p>
<?php if (!empty($this->data['Codtran'])):?>
	<?php if (count($this->data['Codtran'])>1):?>
	<table cellpadding = "0" cellspacing = "0">
	<tr>
		<th width="200"><?php __('Date'); ?></th><th width="180"><?php __('Director'); ?></th>
		<th width="150"><?php __('Transaction'); ?></th><th  width="78"><?php __('Number'); ?></th><th><?php __('Price'); ?></th><th><?php __('Value'); ?></th>
		<!--th><?php __('Holding'); ?></th-->		
	</tr>
	<?php
		$i = 0;
		foreach ($this->data['Codtran'] as $codtran):
			$class = null;
			if ($i++ % 2 == 0) {
				$class = ' class="altrow"';
			}
                        if($i<=5) {
		?>
		<table cellpadding="0" cellspacing="0">
		<tr<?php echo $class;?>><td>
		<?php echo $this->Form->create('Codtran',array('action'=>'edit/'.$codtran['id']));
		echo $this->Form->input('id',array("value"=>$codtran['id']));
		echo $this->Form->input('return_page',array("type"=>'hidden','value'=>'view'));
		echo $this->Form->input('director_id',array("type"=>"hidden",'value'=>$codtran['director_id']));
		?>
		<table cellpadding="0" cellspacing="0">
		<tr>
			<td width="200"><?php echo $this->Form->input('Date',array("value"=>$codtran['Date'],"style"=>"width:60px","label"=>false,"div"=>false,'minYear' => '1950','maxYear' => date("Y"),'dateFormat' => 'DMY', 'empty' => '(choose one)')); ?></td>
			<td width="190"><?php echo $this->Form->input('Name',array("value"=>$codtran['Director']['name'],"label"=>false,"div"=>false)); ?></td>
			<td width="150"><?php echo $this->Form->input('Transaction',array("id"=>"CodtranTransaction_".$codtran['id'],"value"=>$codtran['Transaction'],"label"=>false,"div"=>false)); ?></td>
			<td width="80"><?php echo $this->Form->input('Number',array("id"=>"CodtranNumber_".$codtran['id'],"value"=>$codtran['Number'],"label"=>false,"div"=>false)); ?></td>
			<td width="80"><?php echo $this->Form->input('Price',array("id"=>"CodtranPrice_".$codtran['id'],"value"=>$codtran['Price'],"label"=>false,"div"=>false,'onfocus'=>"calculatePrice(".$codtran['id'].");")); ?></td>
			<td><?php echo $this->Form->input('Value',array("id"=>"CodtranValue_".$codtran['id'],"value"=>$codtran['Value'],"label"=>false,"div"=>false,'onfocus'=>"calculateValue(".$codtran['id'].");")); ?></td>
			<!--td><?php echo $codtran['Holding'];?></td-->			
		</tr></table>
		<div class="deletebtn"><?php echo $this->Html->link(__('Delete', true), array('controller' => 'codtrans', 'action' => 'delete', $codtran['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $codtran['id'])); ?></div>
		<?php $options = array('label' => 'Update','name' => 'Update','div' => false);
		echo $this->Form->end($options);?>
		</td></tr></table>
	<?php }endforeach; ?>
	</table>
	<?php else: ?>
<?php echo $this->Form->create('Codtran',array('action'=>'edit/'.$this->data['Codtran'][0]['id']));
echo $this->Form->input('id',array("value"=>$this->data['Codtran'][0]['id']));
echo $this->Form->input('return_page',array("type"=>'hidden','value'=>'view'));
echo $this->Form->input('director_id',array("type"=>'hidden','value'=>$this->data['Codtran'][0]['director_id']));
//pr($this->data);
?>
<table cellpadding="0" cellspacing="0">
<tr>
<td width="210"><?php echo $this->Form->input('Date',array("value"=>$this->data['Codtran'][0]['Date'],'minYear' => '1950','maxYear' => date("Y"),'dateFormat' => 'DMY')); ?></td>
<td width="160"><?php echo $this->Form->input('Name',array("value"=>$this->data['Codtran'][0]['Director']['name'],"style"=>"width:140px"));?></td>
<td><?php echo $this->Form->input('Transaction',array("value"=>$this->data['Codtran'][0]['Transaction']));?></td>
<td><?php echo $this->Form->input('Number',array("value"=>$this->data['Codtran'][0]['Number']));?></td>
<td><?php echo $this->Form->input('Price',array("value"=>$this->data['Codtran'][0]['Price'],'onfocus'=>"calculatePrice(0);"));?></td>
<td><?php echo $this->Form->input('Value',array("value"=>$this->data['Codtran'][0]['Value'],'onfocus'=>"calculateValue(0);"));?></td>
</tr>
</table>
         
    <?php echo $this->Html->link(__('Delete', true), array('controller' => 'codtrans', 'action' => 'delete',$this->data['Codtran'][0]['id']), array("style"=>"background: -moz-linear-gradient(center top , #A8EA9C, #62AF56) repeat scroll 0 0 #62AF56;
    border-color: #2D6324;border: 1px solid #AAAC62;
    border-radius: 8px 8px 8px 8px;color: #000000;font-weight: normal;
    min-width: 0;padding: 4px 8px;text-decoration: none;
    text-shadow: 0 1px 0 #8CEE7C;"), sprintf(__('Are you sure you want to delete # %s?', true), $this->data['Codtran'][0]['id'])); ?>
	<?php $options = array('label' => 'Update','name' => 'Update','div' => false);
		echo $this->Form->end($options);?>
<?php endif; ?>
<?php endif; 
//print_r($this->data['Codexec']);
if (!empty($this->data['Codexec'])):
    if (count($this->data['Codexec'])>1){
	?>
	<h2><?php __('Former Directors');?></h2>	
	<table cellpadding="1">
	<tr>			
		<th style="width:115px;"><?php __('Name'); ?></th>		
		<th style="width:125px;"><?php __('Title1'); ?></th>
		<th style="width:125px;"><?php __('Title2'); ?></th>
		<th style="width:195px;"><?php __('App'); ?></th>
		<th><?php __('Resig'); ?></th>		
		<th></th>		
	</tr>
	<?php
		$i = 0;
		
		foreach ($this->data['Codexec'] as $dir):
			$class = null;
			
            if($dir["Resig"]!= "0000-00-00"  AND $dir["Resig"]<=date("Y-m-d H:i:s")){
			if ($i++ % 2 == 0) {
				$class = ' class="altrow"';
			}
                        
	?>
	
	<tr<?php echo $class;?>><td colspan="6">
	<?php 
	echo $this->Form->create('Codexec',array('action'=>'edit/'.$dir['id']));
	echo $this->Form->input('id',array("value"=>$dir['id']));
	echo $this->Form->input('director_id',array("value"=>$dir['director_id'],"type"=>"hidden"));
	echo $this->Form->input('return_page',array("type"=>'hidden','value'=>'view'));
	?>
	<table cellpadding="0" cellspacing="1">
		<tr>			
			<td><?php echo $this->Form->input('Codexec.Name',array("style"=>"width:120px","value"=>$dir['Director']['name'],"label"=>false,"div"=>false)); ?></td>			
			<td><?php echo $this->Form->input('Codexec.dir_title_id',array("style"=>"width:120px",'id'=>'CodexecTitle1_1','options'=>$titles,'empty'=>'ADD please',"selected"=>$dir['dir_title_id'],"label"=>false,"div"=>false)); ?></td>
			<td><?php echo $this->Form->input('Codexec.dir_title_id2',array('id'=>'CodexecTitle2_2',"style"=>"width:120px",'options'=>$titles,'empty'=>'ADD please',"selected"=>$dir['dir_title_id2'],"label"=>false,"div"=>false)); ?></td>
			<td width="200"><?php echo $this->Form->input('Codexec.App',array("value"=>$dir['App'],"style"=>"width:60px","label"=>false,"div"=>false,'minYear' => '1950','maxYear' => date("Y"),'dateFormat' => 'DMY', 'empty' => '(choose one)')); ?></td>
			<td width="200"><?php echo $this->Form->input('Codexec.Resig',array("value"=>$dir['Resig'],"style"=>"width:60px","label"=>false,"div"=>false,'minYear' => '1950','maxYear' => date("Y"),'dateFormat' => 'DMY', 'empty' => '(choose one)')); ?></td>
			<td width="10"><?php echo $this->Html->link(__('D', true), array('controller' => 'codexecs', 'action' => 'delete', $dir['id']), array("style"=>"color:red"), sprintf(__('Are you sure you want to delete # %s?', true), $dir['id'])); ?></td>
		</tr>
		</table>	
		<a href="javascript:void(0);" class="addtrans" TranID="<?php echo $dir['id'];?>">TRANS</a><?php //echo $this->Html->link(__('Edit', true), array('controller' => 'codexecs', 'action' => 'edit', $dir['id'])); ?>				
				<?php $options = array('label' => 'Update','name' => 'Update','div' => false);echo $this->Form->end($options);?>			
		</td>
		</tr>
	<?php } endforeach; ?>
	</table>
<?php } endif;?>
</div>

</div>